package com.childenglish.service;

import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class RecommendationService {

    /**
     * 根据学习进度推荐内容
     */
    public List<Map<String, Object>> recommendContent(Long userId, String currentLevel) {
        List<Map<String, Object>> recommendations = new ArrayList<>();

        // 模拟推荐逻辑
        if ("beginner".equals(currentLevel)) {
            recommendations.add(createRecommendation("字母认知游戏", "game", 1));
            recommendations.add(createRecommendation("基础单词听力", "listening", 1));
            recommendations.add(createRecommendation("颜色绘本", "reading", 1));
        } else if ("intermediate".equals(currentLevel)) {
            recommendations.add(createRecommendation("句子构造游戏", "game", 2));
            recommendations.add(createRecommendation("日常对话听力", "listening", 2));
            recommendations.add(createRecommendation("动物世界绘本", "reading", 2));
        } else {
            recommendations.add(createRecommendation("故事理解游戏", "game", 3));
            recommendations.add(createRecommendation("故事听力", "listening", 3));
            recommendations.add(createRecommendation("童话故事绘本", "reading", 3));
        }

        return recommendations;
    }

    private Map<String, Object> createRecommendation(String title, String type, int level) {
        Map<String, Object> recommendation = new HashMap<>();
        recommendation.put("title", title);
        recommendation.put("type", type);
        recommendation.put("level", level);
        recommendation.put("description", "适合当前学习水平的推荐内容");
        recommendation.put("estimatedTime", 15);
        return recommendation;
    }

    /**
     * 个性化推荐
     */
    public List<Map<String, Object>> getPersonalizedRecommendations(Long userId) {
        // 模拟个性化推荐算法
        List<Map<String, Object>> recommendations = new ArrayList<>();

        // 基于用户历史学习数据推荐
        recommendations.add(createRecommendation("个性化单词练习", "game", 2));
        recommendations.add(createRecommendation("定制听力训练", "listening", 2));
        recommendations.add(createRecommendation("兴趣主题绘本", "reading", 2));

        return recommendations;
    }
}